package com.abe.libbase.base;

import android.graphics.Color;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;

import com.abe.libbase.R;
import com.abe.libbase.R2;
import com.abe.libcore.view.recyclerview.CommonAdapter;
import com.abe.libcore.view.recyclerview.MultiItemTypeAdapter;
import com.abe.libcore.view.recyclerview.RecyclerViewTool;
import com.abe.libcore.view.recyclerview.base.ViewHolder;

import java.util.Arrays;

import butterknife.BindView;

public abstract class BaseRecyclerActivity extends BaseActivity implements MultiItemTypeAdapter.OnItemClickListener {

    @BindView(R2.id.item_recycler)
    RecyclerView itemRecycler;
    protected String[] btnNames;
    private CommonAdapter<String> adapter;

    @Override
    public void init() {
        initAdapter();
        itemRecycler.setLayoutManager(new LinearLayoutManager(this));
        itemRecycler.addItemDecoration(RecyclerViewTool.color(this, Color.TRANSPARENT));
        itemRecycler.setAdapter(adapter);
    }

    private void initAdapter() {
        adapter = new CommonAdapter<String>(this, R.layout.item_view_btn, Arrays.asList(btnNames)) {

            @Override
            protected Boolean isAutoZoom() {
                return false;
            }

            @Override
            protected void convert(ViewHolder holder, String s, int position) {
                holder.setText(R.id.item_btn, s);
            }
        };
        adapter.setOnItemClickListener(this);
    }


    @Override
    protected int getLayoutRes() {
        return R.layout.item_view_list;
    }
}